1. Field of the Invention
This invention relates to an apparatus and a method for compensating images being sensed, more particularly to an apparatus and a method for compensating the gray-scale values of an image scanned by a contact image sensor, which is applied to opto-electric products such as facsimile machines, scanners and digital cameras and so on.
2. Description of Prior Art
Normally, the use of a contact image sensor (hereinafter referred to as CIS) to sense an image is based on an assumption that the contact image sensor generates a fixed gray-scale voltage (V.sub.P), such as 1 V, while a white-level pixel is scanned by the contact image sensor, and defining that the gray-scale voltage V.sub.P corresponds to the gray-scale value 255. The gray-scale value of the other pixels is calculated corresponding to the gray-scale value of the white-level pixel. For example, if the CIS scans a pixel and generates an image voltage V.sub.IMG of 0.2 V, the image voltage V.sub.IMG is one-fifth of the gray-scale voltage V.sub.P. In other words, the gray-scale value of the scanned pixel equals to 51 (i.e., 255.times.0.2/1).
According to the specification of today's commercial CISs, the white-level voltage of a CIS is normally variable between 0.8 V and 1.2 V for different manufacturers. Furthermore, there is an uniformity problem in a CIS due to the manufacturing errors and the substantial error of the CIS itself. The output V.sub.POUT of white-level voltage of the CIS is V.sub.P.+-.30% V. Referring to FIG. 1, it is possible to generate a high voltage while a white-level pixel is right under the light source element 5 such as when the LED of the CIS is scanned by the sensor 6, and a low voltage while a white-level pixel positioned between two light source elements 5 is scanned. Hence, different white-level voltages V.sub.P can be generated by scanning identical white-level pixels. Accordingly, a possible white-level voltage output of a CIS varies in a range from 0.56 V to 1.56 V for different manufacturers. The highest reference voltage is therefore defined as 1.6 V in the embodiment described later.
Due to this white-level uniformity problem, the voltages V.sub.P being output may not be identical when scanning different white-level pixels. The difference that occurs in the white-level voltage output may cause gray-scale distortion of an image being output. For example, a CIS that can actually output a white-level voltage V.sub.P of 0.9 V, which is defined as 1 V in the spec., scans a pixel and generates an image voltage V.sub.IMG of 0.45 V. The correct gray-scale value for the pixel should be 128 (=255.times.0.45/0.9). However, according to the spec., the CIS outputs a gray-scale value of 114 (=255.times.0.45/1) for the pixel. This causes the gray-scale value of the pixel to be too low, and the color of the image at the pixel is too light. Therefore, it is necessary to compensate the gray-scale value of an image being scanned in the image reading device, which has a CIS element in the reading portion thereof, such as a facsimile machine, a scanner or a digital camera.
At the present, most of the image-compensating technologies used in a CIS of an image-reading device involve use of an analog/digital converter, digital/analog converter and an operational amplifier. Referring to FIG. 2, a conventional image-compensating device for a CIS includes: a microprocessor 10; a memory 12; a digital/analog converter 14; a CIS 16; a sample-and-hold circuit 18; an operational amplifier 20; and an analog/digital converter 22. The image-compensating device works according to the following procedures:
(1) The voltage output V.sub.P defined in the spec. of the CIS is first output to the V.sub.TOP terminal of the analog/digital converter 22. The transversal axis of the CIS 16 is assumed to extend along x-coordinate, and the CIS scans a white plate along y-coordinate for 20 scan-lines of pixels (i.e., from y=0 to y=19). Then the white-level voltage outputs of the pixels are output to the analog/digital converter 22 to generate the white-level value G(x,y) of each pixel, where 0.ltoreq.y.ltoreq.19 and x varies with the width of the CIS, that is, a wider CIS can scan a larger range along the x-coordinate direction.
(2) According to the white-level values obtained in the previous step, for each scan line, an average white-level value G'(x) is calculated by the following equation: EQU G'(x)=[G(x,0)+G(x,1)+G(x,2)+ . . . +G(x,19)]/20,
and the average value G'(x) is stored in the memory 12.
(3) The average gray-scale value G'(x) corresponding to each x-coordinate stored in the memory is retrieved by a microprocessor 10 and output to the digital/analog converter 14, so that the digital/analog converter 14 can sequentially generate an average white-level voltage output V'.sub.P corresponding to each x-coordinate in the next step.
(4) When the CIS 16 is reading image data, it is operated as follows: the transversal axis of the CIS 16 extends along the x-coordinate, and the CIS 16 moves in the y-coordinate direction. The CIS 16 sequentially reads a plurality of pixels corresponding to a y-coordinate as they move along a direction of increasing x-coordinate values. The voltage outputs V.sub.IMG generated corresponding to the plurality of pixels are sequentially input to the terminal Analog of the analog/digital converter 22. While inputting the voltage V.sub.IMG of some x-coordinate, the average white-level voltage V.sub.P ' is simultaneously input to the terminal V.sub.TOP of the analog/digital converter 22. Then the compensated gray-scale values of the pixels on the x-coordinate can be calculated by V.sub.IMG and the corresponding V.sub.P '.
Compensating the gray-scale of an image by such analog technology involves not only a high initial cost but also a complex structure. For instance, the conventional image compensating device requires that the digital/analog converter 14 convert digital gray-scale values into analog voltages to perform gray-scale compensation since the memory can only store digital data. Further, different voltages V.sub.P ' are required for the terminal V.sub.TOP of the analog/digital converter while compensating the gray-scales of the pixels of different x-coordinates. Therefore, the analog/digital converter cannot compare V.sub.IMG /V.sub.TOP until the voltage V.sub.P ' input to the terminal V.sub.TOP is stable. A next pixel is then sampled after the comparing operation. This results in a slow operating speed of the compensating device. A sample-and-hold circuit is needed to sample the image voltage V.sub.IMG of the pixel being scanned and to hold the sampled voltage for a predetermined period.